package com.arpa.oms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;


/**
 * @description OMS收款单、付款单状态：新增、待审核、审核通过、审核未通过
 *
 * @author leo
 * @date 2020/10/23
 **/
public enum PayableAndReceivableStatusEnum implements IEnum<String> {
    // 采购单类型
    NEWS("NEWS","新增"),
    PENDING("PENDING","待审核"),
    PASS("PASS","审核通过"),
    NO_PASS("NO_PASS","审核未通过");

    /**
     * 值
     */
    @EnumValue
    private final String value;

    /**
     * 描述
     */
    private final String desc;

    PayableAndReceivableStatusEnum(final String value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static final Map<String, PayableAndReceivableStatusEnum> map = new HashMap();

    static {
        PayableAndReceivableStatusEnum[] values = values();
        int length = values.length;
        for(int i = 0; i < length; i++){
            PayableAndReceivableStatusEnum value1 = values[i];
            map.put(value1.getValue(),value1);
        }
    }

    public static PayableAndReceivableStatusEnum getEnumByValue(String value){
        return map.get(value);
    }

    /**
     * 翻译
     * @param value
     * @return
     */
    public static String translate(String value){
        PayableAndReceivableStatusEnum item = map.get(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }


    @Override
    public String getValue() {
        return this.value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return this.desc;
    }
}
